package com.bosssoft.hr.train.j2se.collection;

import com.bosssoft.hr.train.j2se.pojo.entity.User;

import java.sql.SQLOutput;
import java.util.HashMap;
import java.util.Map;

/**
 * HashMapDem
 */
public class HashMapDemo {
    private Map<Long, User> userHashMap = new HashMap<>();
    User[] users =new User[10];

    /**
     * 创建测试数据
     * @return 用户数组
     */
    public User[] getUsers() {
        for(int i = 0; i < 10; i++){
            users[i] =new User(new Long(i),"BossSoft"+i,"用户"+i);
        }
        return users;
    }

    /**
     * 遍历
     */
    public void visitUserHashMap(){
        users = getUsers();
        for(User user : users){
            userHashMap.put(user.getId(),user);
        }
        for (Map.Entry<Long,User> entry : userHashMap.entrySet()){
            System.out.println(entry.getKey().toString() + "####" + entry.getValue());
        }
    }
}
